/* eslint-disable prettier/prettier */
import { BasicColumn, FormSchema } from '@/components/Table';
import { ifShow, ifDescription } from '@/utils/schema_util'
/**
 * 表格列配置
 */
export const tableColumns: BasicColumn[] = [
  {
    title: '分组编码',
    dataIndex: 'groupCode',
    component: 'ApiDict',
    componentProps: {
      code: "sys_dict_group_code",
      dataType: "number",
      placeholder: "请选择分组编码",
    }
  },
  {
    title: '字典名称',
    dataIndex: 'name',
    component: 'Input',
    componentProps: {
      placeholder: "请输入字典名称",
    }
  },
  {
    title: '唯一编码',
    dataIndex: 'code',
    component: 'Input',
    componentProps: {
      placeholder: "请输入唯一编码",
    }
  },
  {
    title: '数据类型',
    dataIndex: 'dataType',
    component: 'ApiDict',
    componentProps: {
      code: "sys_dict_data_type",
      dataType: "number",
      placeholder: "请选择数据类型",
    }
  },
  {
    title: '是否启用',
    dataIndex: 'enabled',
    component: 'ApiDict',
    componentProps: {
      code: "yes_no",
      dataType: "number",
      renderType: "RadioGroup",
      placeholder: "请选择是否启用",
      isBtn: true,
    }
  },
  {
    title: '排序',
    dataIndex: 'sort',
    component: 'Input',
    componentProps: {
      type: "number",
      placeholder: "请输入排序",
    }
  },
  {
    title: '备注',
    dataIndex: 'remark',
    component: 'InputTextArea',
    componentProps: {
      showCount: true,
      placeholder: "请输入备注",
    }
  },
  {
    title: '操作',
    dataIndex: '__ACTION__',
  },
];
/**
 * 搜索表单配置
 */
export const searchFormSchemas: FormSchema[] = [
  {
    label: '字典名称',
    field: 'm_LIKE_name',
    component: 'Input',
    componentProps: {
      placeholder: "请输入字典名称",
    } as any,
    colProps: { span: 6 },
  },
  {
    label: '唯一编码',
    field: 'm_LIKE_code',
    component: 'Input',
    componentProps: {
      placeholder: "请输入唯一编码",
    } as any,
    colProps: { span: 6 },
  },
];

/**
 * 新增、编辑表单配置
 */
export const formSchemas: FormSchema[] = [
  {
    field: 'id',
    label: '字典ID',
    component: 'Input',
    show: false,
    description: false,
    componentProps: {
      type: "hidden",
      placeholder: "请输入字典ID",
    } as any,
    required: false,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"addHide":1,"editHide":0,"listHide":1,"viewHide":1,"addDisabled":0,"editDisabled":0,"required":0,"search":0,"Input_type":"hidden"}
      return ifShow(data,ext);
    },
  },
  {
    field: 'groupCode',
    label: '分组编码',
    component: 'ApiDict',
    description: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":0,"ApiDict_code":"sys_dict_group_code","ApiDict_dataType":"number","popupContainerInBody":false}
      return ifDescription(data,ext);
    },
    componentProps: {
      code: "sys_dict_group_code",
      dataType: "number",
      placeholder: "请选择分组编码",
    } as any,
    required: true,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":0,"ApiDict_code":"sys_dict_group_code","ApiDict_dataType":"number","popupContainerInBody":false}
      return ifShow(data,ext);
    },
  },
  {
    field: 'name',
    label: '字典名称',
    component: 'Input',
    description: (data) => {
      const ext = {"searchType":"LIKE","addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":1}
      return ifDescription(data,ext);
    },
    componentProps: {
      placeholder: "请输入字典名称",
    } as any,
    required: true,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"searchType":"LIKE","addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":1}
      return ifShow(data,ext);
    },
  },
  {
    field: 'code',
    label: '唯一编码',
    component: 'Input',
    description: (data) => {
      const ext = {"searchType":"LIKE","addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":1}
      return ifDescription(data,ext);
    },
    componentProps: {
      placeholder: "请输入唯一编码",
    } as any,
    required: true,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"searchType":"LIKE","addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":1}
      return ifShow(data,ext);
    },
  },
  {
    field: 'dataType',
    label: '数据类型',
    component: 'ApiDict',
    description: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":0,"ApiDict_code":"sys_dict_data_type","ApiDict_dataType":"number","popupContainerInBody":false}
      return ifDescription(data,ext);
    },
    defaultValue: 1,
    componentProps: {
      code: "sys_dict_data_type",
      dataType: "number",
      placeholder: "请选择数据类型",
    } as any,
    required: true,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":0,"ApiDict_code":"sys_dict_data_type","ApiDict_dataType":"number","popupContainerInBody":false}
      return ifShow(data,ext);
    },
  },
  {
    field: 'enabled',
    label: '是否启用',
    component: 'ApiDict',
    description: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":0,"ApiDict_code":"yes_no","ApiDict_dataType":"number","ApiDict_renderType":"RadioGroup","popupContainerInBody":false}
      return ifDescription(data,ext);
    },
    defaultValue: 1,
    componentProps: {
      code: "yes_no",
      dataType: "number",
      renderType: "RadioGroup",
      placeholder: "请选择是否启用",
      isBtn: true,
    } as any,
    required: true,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":1,"search":0,"ApiDict_code":"yes_no","ApiDict_dataType":"number","ApiDict_renderType":"RadioGroup","popupContainerInBody":false}
      return ifShow(data,ext);
    },
  },
  {
    field: 'sort',
    label: '排序',
    component: 'Input',
    description: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":0,"search":0,"Input_type":"number"}
      return ifDescription(data,ext);
    },
    defaultValue: "999",
    componentProps: {
      type: "number",
      placeholder: "请输入排序",
    } as any,
    required: false,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":0,"search":0,"Input_type":"number"}
      return ifShow(data,ext);
    },
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    description: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":0,"search":0,"InputTextArea_showCount":true}
      return ifDescription(data,ext);
    },
    componentProps: {
      showCount: true,
      placeholder: "请输入备注",
    } as any,
    required: false,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":0,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":0,"search":0,"InputTextArea_showCount":true}
      return ifShow(data,ext);
    },
  },
  {
    field: 'dictItemList',
    label: '字典项',
    component: 'DictItem'as any ,
    description: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":1,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":0,"search":0,"CustomComponent_componentName":"DictItem"}
      return ifDescription(data,ext);
    },
    componentProps: {
      placeholder: "请输入字典项",
    } as any,
    required: false,
    colProps: { span: 24 },
    ifShow: (data) => {
      const ext = {"addHide":0,"editHide":0,"listHide":1,"viewHide":0,"addDisabled":0,"editDisabled":0,"required":0,"search":0,"CustomComponent_componentName":"DictItem"}
      return ifShow(data,ext);
    },
  },
];
